package com.twu.biblioteca;


import java.util.List;

public class BibliotecaMembershipDetails implements BibliotecaCommand {

    private BibliotecaApp bibliotecaApp;

    public BibliotecaMembershipDetails(BibliotecaApp bibliotecaApp) {

        this.bibliotecaApp = bibliotecaApp;
    }

    public void execute() {

        List<BibliotecaUser> userList = bibliotecaApp.getUserList();

        String[] loginCredentials = bibliotecaApp.getUserCredentials();

        String outputMessage = null;
        for (BibliotecaUser user : userList) {

            if (user.confirmCredentials(loginCredentials[0], loginCredentials[1])) {
                outputMessage = user.toString();
                break;
            }
            else {
                outputMessage = "Please talk to a Librarian. Thank you.";
            }
        }

        bibliotecaApp.outputMessage(outputMessage);
     }
}
